package com.jushu.storbox.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NameUtils {

	/** NameUtils TAG */
	private static final String TAG = "NameUtils";


	private static final String PATTERN_STR_FILENAME = "[^/\\\\]{1,255}";

	private static final Pattern PATTERN_FILENAME = Pattern
			.compile(PATTERN_STR_FILENAME);

	/**
	 * TODO FileListAdapter Controller function, cannot be instantiated
	 */
	

	public static boolean isValidFileName(String fileName) {
		if (!isFormatFileName(fileName) || fileName.endsWith(".")
				|| fileName.startsWith(".")) {
			return false;
		}else{
			return true;
		}
	}

	private static boolean isFormatFileName(String name) {
		if (null == name || name.trim().equals("")) {
			return false;
		}

		Matcher m = PATTERN_FILENAME.matcher(name);
		return m.matches();
	}
	
}
